#ifndef G3_GEOMETRY_POINTER_H
#define G3_GEOMETRY_POINTER_H

#include "GLee/GLee.h"

#include "math/m_vector.h"

#include "material.h"

namespace G3 {

class GEOM_POINTER {
    public:
        /**
            @brief A constructor
        */
        GEOM_POINTER ();
        /**
            A destructor
        */
        ~GEOM_POINTER ();

        /** Pointer to the vertices */
        G3::VEC3F *vertices;
        /** Pointer to the texture coordinates */
        G3::VEC2F *texcoords;
        /** Pointer to the normals */
        G3::VEC3F *normals;
        /** Pointer to the tangents */
        G3::VEC3F *tangents;
        /** Number of vertices */
        uint num_vertices;
        /** Number of indexes */
        uint num_indexes;
        /** Pointer to the indexes */
        uint *indexes;
        /** Number of materials */
        uint num_materials;
        /** Pointer to materials */
        G3::MATERIAL *materials;

        /** Pointer to the log */
        G3::LOG *log;

        /**
            @brief Binds a material
            @param[in] mat_id Material ID
            @return True on success, false on failure
        */
        bool bind_material (int mat_id);

        /**
            @brief Unbinds the last bound material
            @return True on success, false on failure
        */
        bool unbind_material ();

        /**
            @brief Initializes the Geometry pointer
            @param[in] nv Number of vertices
            @param[in] v Pointer to the vertices
            @param[in] nid Number of indexes
            @param[in] id Pointer to the indexes
            @param[in] nm Number of materials
            @param[in] m Pointer to the materials
            @param[in] uv Pointer to the texture coordinates (defaults to NULL)
            @param[in] n Pointer to the normals  (defaults to NULL)
            @param[in] t Pointer to the tangents (defaults to NULL)
            \todo Tangent buffers ?
        */
        void init (uint nv, G3::VEC3F *v, uint nid, uint *id, uint nm, G3::MATERIAL *m = NULL, G3::VEC2F *uv = NULL, G3::VEC3F *n = NULL, G3::VEC3F *t = NULL);

        void clear ();

    protected:
        /** Is a material applied */
        bool material_applied;
        /** Index of the last material */
        uint current_material;
};

}

#endif // G3_GEOMETRY_POINTER_H
